<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script src="{{ getAssets }}js/jquery.table2excel.min.js?v={{ assets_version }}"></script>
<script>
	var tables = $('#dataTables').DataTable({
		"sAjaxSource" : '{{ urlfor "EntryreturnController.Flushing"}}'
		,"bLengthChange": false
		,"fnServerData" : function(sSource, aoData, fnCallback) {
			var params = checkQueryTableData(aoData);
            params.entry_no = $('#entry_no').val();
            params.entry_user = $('#entry_user').val();
            params.flowing_no = $('#flowing_no').val();
            params.flowing_user = $('#flowing_user').val();
            params.start_date = $('#start_date').val();
            params.end_date = $('#end_date').val();
			$.post(sSource, JSON.stringify(params),function(resp) {
				fnCallback(resp);
			},'json')
		}
		,columns: [
			{"bSortable": false, render:function(data, type, full, meta) {
				return full.Number;
			}}

            ,{"bSortable": false, render:function(data, type, full, meta) {
                   return full.Entry.Suppliers ? full.Entry.Suppliers.Name : '';
            }}

            ,{"bSortable": false,render:function(data, type, full, meta) {
                    return full.FlowingUser;
             }}
            ,{"bSortable": false,render:function(data, type, full, meta) {
                    return timetransDate(full.FlowingDate);
            }}
			,{"bSortable": false, render:function(data, type, full, meta) {
				return full.FlowingNum;
			}}
			,{   
				"mDataProp": "Action", 
				"bSortable": false, 
				"sWidth":"10%",
				"render": function ( data, type, full, meta ) { 
					btns = '';
                    btns += '&nbsp;<a class="am-btn am-btn-success am-btn-xs"  onclick="showDetails('+ full.Id +');return false;">冲红</a>';

					return btns;  
				}  
			 } 
		]
		,"aLengthMenu":[20, 50, 100, 200]
		,'bLengthChange': true
		,"serverSide": true
		,"bPaginate" : true
		,"bFilter" : false	//是否启动过滤、搜索功能 
		,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
		,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示  
	});
	
	$("#query-submit").bind("click", function () { //点击按钮 触发table重新请求服务器
		$("#dataTables").dataTable().fnDraw(false);
	});

    function showDetails(id){
        var url = '{{urlfor "EntryreturnController.Details"}}/'+id;
        layer.open({
            type: 2,
            title: "采购冲红",
            shadeClose: false,
            shade: 0.2,
            maxmin: true,
            shift: 1,
            area: ['85%', '80%'],
            content: url
        });
        return false;
    }

    function dialogClose() {
        layer.closeAll();
        $("#dataTables").dataTable().fnDraw(false);
    }
</script>